<?php
$nowdate=date('Y-m-d');
if(empty($RTLS1)) { $date_result="0"; }
else
{
$mydate=$RTLS1->TANGGAL;

$year_format1=date("Y", strtotime($nowdate));
$year_format2=date("Y", strtotime($mydate));
$year_result=($year_format1-$year_format2)*12; 

$month_format1=date("m", strtotime($mydate));
$month_format2 = strtotime("-".$month_format1." month",strtotime($nowdate));
$month_format3=date("m", strtotime($nowdate));
if($month_format3==$month_format1) { $month_result="0"; } else { $month_result = date("m", $month_format2); }

$date_result=$year_result+$month_result;
}
?>
<div class="form-group">
<div class ="container">
<form class="form-horizontal" role="form" action="<?php echo site_url('pembul/input_form');?>" method="post">
<label>Bagian</label>
<input class="form-control" id="bagian" type="text" name="bagian" maxlength="50" value="<?php echo $this->session->userdata('bagian'); ?>" readonly required ></br>
<label>Departemen </label>
<input class="form-control" id="departemen" type="text" readonly name="departemen" maxlength="50" value="<?php echo $this->session->userdata('departemen'); ?>" required ></br>
<label>Tanggal</label>
<input class="form-control" id="-datepicker" type="text" name="tanggal" maxlength="50" value="<?php echo date("Y-m-d"); ?>" readonly required ></br>

</br></br></div>
 <div class="container">
 
 <table class="table table-bordered table-condensed">
 <thead>
        <tr>
          <th>No</th>
          <th>Hasil Temuan</th>
          <th>Temuan Berulang Ke</th>
          <th>Tindak Lanjut</th>
		  <th>Status</th>
        </tr>
      </thead>
	  <tbody>
        <tr>
		<td>I</td>
          <td><b>Sikap Tidak Aman</b></td>
         
 <td>
 </td>
  <td>
 </td>
 <td>
 </td>
        </tr>
		<tr>
		<td></td>
		<?php
		if(empty($RTLS1)) { $RTLS1_1=""; $RTLS1_2="1"; $RTLS1_3=""; $RTLS1_4=""; }
		else { $RTLS1_1=$RTLS1->S1; $RTLS1_2=$RTLS1->TBS1+$date_result; $RTLS1_3=$RTLS1->TLS1; $RTLS1_4=$RTLS1->RTLS1; }
		
		if(empty($RTLS2)) { $RTLS2_1=""; $RTLS2_2="1"; $RTLS2_3=""; $RTLS2_4=""; }
		else { $RTLS2_1=$RTLS2->S2; $RTLS2_2=$RTLS2->TBS2+$date_result; $RTLS2_3=$RTLS2->TLS2; $RTLS2_4=$RTLS2->RTLS2; }
		
		if(empty($RTLS3)) { $RTLS3_1=""; $RTLS3_2="1"; $RTLS3_3=""; $RTLS3_4=""; }
		else { $RTLS3_1=$RTLS3->S3; $RTLS3_2=$RTLS3->TBS3+$date_result; $RTLS3_3=$RTLS3->TLS3; $RTLS3_4=$RTLS3->RTLS3; }
		
		if(empty($RTLS4)) { $RTLS4_1=""; $RTLS4_2="1"; $RTLS4_3=""; $RTLS4_4=""; }
		else { $RTLS4_1=$RTLS4->S4; $RTLS4_2=$RTLS4->TBS4+$date_result; $RTLS4_3=$RTLS4->TLS4; $RTLS4_4=$RTLS4->RTLS4; }
		
		if(empty($RTLS5)) { $RTLS5_1=""; $RTLS5_2="1"; $RTLS5_3=""; $RTLS5_4=""; }
		else { $RTLS5_1=$RTLS5->S5; $RTLS5_2=$RTLS5->TBS5+$date_result; $RTLS5_3=$RTLS5->TLS5; $RTLS5_4=$RTLS5->RTLS5; }
		/*
		if(empty($RTLS1)) { $RTLS1_1=""; $RTLS1_2="1"; $RTLS1_3=""; $RTLS1_4=""; }
		else { $RTLS1_1=$RTLS1->S1; $RTLS1_2=$RTLS1->TBS1+1; $RTLS1_3=$RTLS1->TLS1; $RTLS1_4=$RTLS1->RTLS1; }
		
		if(empty($RTLS2)) { $RTLS2_1=""; $RTLS2_2="1"; $RTLS2_3=""; $RTLS2_4=""; }
		else { $RTLS2_1=$RTLS2->S2; $RTLS2_2=$RTLS2->TBS2+1; $RTLS2_3=$RTLS2->TLS2; $RTLS2_4=$RTLS2->RTLS2; }
		
		if(empty($RTLS3)) { $RTLS3_1=""; $RTLS3_2="1"; $RTLS3_3=""; $RTLS3_4=""; }
		else { $RTLS3_1=$RTLS3->S3; $RTLS3_2=$RTLS3->TBS3+1; $RTLS3_3=$RTLS3->TLS3; $RTLS3_4=$RTLS3->RTLS3; }
		
		if(empty($RTLS4)) { $RTLS4_1=""; $RTLS4_2="1"; $RTLS4_3=""; $RTLS4_4=""; }
		else { $RTLS4_1=$RTLS4->S4; $RTLS4_2=$RTLS4->TBS4+1; $RTLS4_3=$RTLS4->TLS4; $RTLS4_4=$RTLS4->RTLS4; }
		
		if(empty($RTLS5)) { $RTLS5_1=""; $RTLS5_2="1"; $RTLS5_3=""; $RTLS5_4=""; }
		else { $RTLS5_1=$RTLS5->S5; $RTLS5_2=$RTLS5->TBS5+1; $RTLS5_3=$RTLS5->TLS5; $RTLS5_4=$RTLS5->RTLS5; }
		*/
		?>
		<td><input class="form-control" id="sta1" type="text" name="sta1" maxlength="50" value="<?php echo $RTLS1_1; ?>" /></br>
		<input class="form-control" id="sta2" type="text" name="sta2" maxlength="50" value="<?php echo $RTLS2_1; ?>" /></br>
		<input class="form-control" id="sta3" type="text" name="sta3" maxlength="50" value="<?php echo $RTLS3_1; ?>" /></br>
		<input class="form-control" id="sta4" type="text" name="sta4" maxlength="50" value="<?php echo $RTLS4_1; ?>" /></br>
		<input class="form-control" id="sta5" type="text" name="sta5" maxlength="50" value="<?php echo $RTLS5_1; ?>" /></td>
		<td><input class="form-control" id="tbk1" type="text" name="tbk1" maxlength="50" value="<?php echo $RTLS1_2; ?>" readonly /></br>
		<input class="form-control" id="tbk2" type="text" name="tbk2" maxlength="50" value="<?php echo $RTLS2_2; ?>" readonly /></br>
		<input class="form-control" id="tbk3" type="text" name="tbk3" maxlength="50" value="<?php echo $RTLS3_2; ?>" readonly /></br>
		<input class="form-control" id="tbk4" type="text" name="tbk4" maxlength="50" value="<?php echo $RTLS4_2; ?>" readonly /></br>
		<input class="form-control" id="tbk5" type="text" name="tbk5" maxlength="50" value="<?php echo $RTLS5_2; ?>" readonly /></td>
		<td><input class="form-control" id="tar1" type="text" name="tar1" maxlength="50" value="<?php echo $RTLS1_3; ?>" /></br>
		<input class="form-control" id="tar2" type="text" name="tar2" maxlength="50" value="<?php echo $RTLS2_3; ?>" /></br>
		<input class="form-control" id="tar3" type="text" name="tar3" maxlength="50" value="<?php echo $RTLS3_3; ?>" /></br>
		<input class="form-control" id="tar4" type="text" name="tar4" maxlength="50" value="<?php echo $RTLS4_3; ?>" /></br>
		<input class="form-control" id="tar5" type="text" name="tar5" maxlength="50" value="<?php echo $RTLS5_3; ?>" /></td>
		<td>
		<select name="s1" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="s2" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="s3" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="s4" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="s5" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
</td>
		</tr>
		
		<tr>
		<td>II</td>
          <td><b>Kondisi Tidak Aman</b></td>
           <td>
 </td>
 <td>
 </td>
 <td>
 </td>
        </tr>
		<tr>
		<td></td>
		<?php
		if(empty($RTLK1)) { $RTLK1_1=""; $RTLK1_2="1"; $RTLK1_3=""; $RTLK1_4=""; }
		else { $RTLK1_1=$RTLK1->K1; $RTLK1_2=$RTLK1->TBK1+$date_result; $RTLK1_3=$RTLK1->TLK1; $RTLK1_4=$RTLK1->RTLK1; }
		
		if(empty($RTLK2)) { $RTLK2_1=""; $RTLK2_2="1"; $RTLK2_3=""; $RTLK2_4=""; }
		else { $RTLK2_1=$RTLK2->K2; $RTLK2_2=$RTLK2->TBK2+$date_result; $RTLK2_3=$RTLK2->TLK2; $RTLK2_4=$RTLK2->RTLK2; }
		
		if(empty($RTLK3)) { $RTLK3_1=""; $RTLK3_2="1"; $RTLK3_3=""; $RTLK3_4=""; }
		else { $RTLK3_1=$RTLK3->K3; $RTLK3_2=$RTLK3->TBK3+$date_result; $RTLK3_3=$RTLK3->TLK3; $RTLK3_4=$RTLK3->RTLK3; }
		
		if(empty($RTLK4)) { $RTLK4_1=""; $RTLK4_2="1"; $RTLK4_3=""; $RTLK4_4=""; }
		else { $RTLK4_1=$RTLK4->K4; $RTLK4_2=$RTLK4->TBK4+$date_result; $RTLK4_3=$RTLK4->TLK4; $RTLK4_4=$RTLK4->RTLK4; }
		
		if(empty($RTLK5)) { $RTLK5_1=""; $RTLK5_2="1"; $RTLK5_3=""; $RTLK5_4=""; }
		else { $RTLK5_1=$RTLK5->K5; $RTLK5_2=$RTLK5->TBK5+$date_result; $RTLK5_3=$RTLK5->TLK5; $RTLK5_4=$RTLK5->RTLK5; }
		/*
		if(empty($RTLK1)) { $RTLK1_1=""; $RTLK1_2="1"; $RTLK1_3=""; $RTLK1_4=""; }
		else { $RTLK1_1=$RTLK1->K1; $RTLK1_2=$RTLK1->TBK1+1; $RTLK1_3=$RTLK1->TLK1; $RTLK1_4=$RTLK1->RTLK1; }
		
		if(empty($RTLK2)) { $RTLK2_1=""; $RTLK2_2="1"; $RTLK2_3=""; $RTLK2_4=""; }
		else { $RTLK2_1=$RTLK2->K2; $RTLK2_2=$RTLK2->TBK2+1; $RTLK2_3=$RTLK2->TLK2; $RTLK2_4=$RTLK2->RTLK2; }
		
		if(empty($RTLK3)) { $RTLK3_1=""; $RTLK3_2="1"; $RTLK3_3=""; $RTLK3_4=""; }
		else { $RTLK3_1=$RTLK3->K3; $RTLK3_2=$RTLK3->TBK3+1; $RTLK3_3=$RTLK3->TLK3; $RTLK3_4=$RTLK3->RTLK3; }
		
		if(empty($RTLK4)) { $RTLK4_1=""; $RTLK4_2="1"; $RTLK4_3=""; $RTLK4_4=""; }
		else { $RTLK4_1=$RTLK4->K4; $RTLK4_2=$RTLK4->TBK4+1; $RTLK4_3=$RTLK4->TLK4; $RTLK4_4=$RTLK4->RTLK4; }
		
		if(empty($RTLK5)) { $RTLK5_1=""; $RTLK5_2="1"; $RTLK5_3=""; $RTLK5_4=""; }
		else { $RTLK5_1=$RTLK5->K5; $RTLK5_2=$RTLK5->TBK5+1; $RTLK5_3=$RTLK5->TLK5; $RTLK5_4=$RTLK5->RTLK5; }
		*/
		?>
		<td><input class="form-control" id="kta1" type="text" name="kta1" maxlength="50" value="<?php echo $RTLK1_1; ?>" /></br>
		<input class="form-control" id="kta2" type="text" name="kta2" maxlength="50" value="<?php echo $RTLK2_1; ?>" /></br>
		<input class="form-control" id="kta3" type="text" name="kta3" maxlength="50" value="<?php echo $RTLK3_1; ?>" /></br>
		<input class="form-control" id="kta4" type="text" name="kta4" maxlength="50" value="<?php echo $RTLK4_1; ?>" /></br>
		<input class="form-control" id="kta5" type="text" name="kta5" maxlength="50" value="<?php echo $RTLK5_1; ?>" /></td>
		<td><input class="form-control" id="rtl6" type="text" name="rt6" maxlength="50" value="<?php echo $RTLK1_2; ?>" readonly /></br>
		<input class="form-control" id="rtl7" type="text" name="rt7" maxlength="50" value="<?php echo $RTLK2_2; ?>" readonly /></br>
		<input class="form-control" id="rtl8" type="text" name="rt8" maxlength="50" value="<?php echo $RTLK3_2; ?>" readonly /></br>
		<input class="form-control" id="rtl9" type="text" name="rt9" maxlength="50" value="<?php echo $RTLK4_2; ?>" readonly /></br>
		<input class="form-control" id="rtl10" type="text" name="rt10" maxlength="50" value="<?php echo $RTLK5_2; ?>" readonly /></td>
		<td><input class="form-control" id="tar6" type="text" name="tar6" maxlength="50" value="<?php echo $RTLK1_3; ?>" /></br>
		<input class="form-control" id="tar7" type="text" name="tar7" maxlength="50" value="<?php echo $RTLK2_3; ?>" /></br>
		<input class="form-control" id="tar8" type="text" name="tar8" maxlength="50" value="<?php echo $RTLK3_3; ?>" /></br>
		<input class="form-control" id="tar9" type="text" name="tar9" maxlength="50" value="<?php echo $RTLK4_3; ?>" /></br>
		<input class="form-control" id="tar10" type="text" name="tar10" maxlength="50" value="<?php echo $RTLK5_3; ?>" /></td>
		<td>
<select name="k1" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="k2" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="k3" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="k4" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
		<select name="k5" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
</td>
		</tr>
		
		<tr>
		<td>III</td>
          <td><b>Lingkungan Kerja</b></td>
           <td>
 </td>
 <td>
 </td>
 <td>
 </td>
        </tr>
		<tr>
		<td></td>
		<?php
		if(empty($RTLG1)) { $RTLG1_1=""; $RTLG1_2="1"; $RTLG1_3=""; $RTLG1_4=""; }
		else { $RTLG1_1=$RTLG1->G1; $RTLG1_2=$RTLG1->TBG1+$date_result; $RTLG1_3=$RTLG1->TLG1; $RTLG1_4=$RTLG1->RTLG1; }
		
		if(empty($RTLG2)) { $RTLG2_1=""; $RTLG2_2="1"; $RTLG2_3=""; $RTLG2_4=""; }
		else { $RTLG2_1=$RTLG2->G2; $RTLG2_2=$RTLG2->TBG2+$date_result; $RTLG2_3=$RTLG2->TLG2; $RTLG2_4=$RTLG2->RTLG2; }
		
		if(empty($RTLG3)) { $RTLG3_1=""; $RTLG3_2="1"; $RTLG3_3=""; $RTLG3_4=""; }
		else { $RTLG3_1=$RTLG3->G3; $RTLG3_2=$RTLG3->TBG3+$date_result; $RTLG3_3=$RTLG3->TLG3; $RTLG3_4=$RTLG3->RTLG3; }
		
		if(empty($RTLG4)) { $RTLG4_1=""; $RTLG4_2="1"; $RTLG4_3=""; $RTLG4_4=""; }
		else { $RTLG4_1=$RTLG4->G4; $RTLG4_2=$RTLG4->TBG4+$date_result; $RTLG4_3=$RTLG4->TLG4; $RTLG4_4=$RTLG4->RTLG4; }
		
		if(empty($RTLG5)) { $RTLG5_1=""; $RTLG5_2="1"; $RTLG5_3=""; $RTLG5_4=""; }
		else { $RTLG5_1=$RTLG5->G5; $RTLG5_2=$RTLG5->TBG5+$date_result; $RTLG5_3=$RTLG5->TLG5; $RTLG5_4=$RTLG5->RTLG5; }
		/*
		if(empty($RTLG1)) { $RTLG1_1=""; $RTLG1_2="1"; $RTLG1_3=""; $RTLG1_4=""; }
		else { $RTLG1_1=$RTLG1->G1; $RTLG1_2=$RTLG1->TBG1+1; $RTLG1_3=$RTLG1->TLG1; $RTLG1_4=$RTLG1->RTLG1; }
		
		if(empty($RTLG2)) { $RTLG2_1=""; $RTLG2_2="1"; $RTLG2_3=""; $RTLG2_4=""; }
		else { $RTLG2_1=$RTLG2->G2; $RTLG2_2=$RTLG2->TBG2+1; $RTLG2_3=$RTLG2->TLG2; $RTLG2_4=$RTLG2->RTLG2; }
		
		if(empty($RTLG3)) { $RTLG3_1=""; $RTLG3_2="1"; $RTLG3_3=""; $RTLG3_4=""; }
		else { $RTLG3_1=$RTLG3->G3; $RTLG3_2=$RTLG3->TBG3+1; $RTLG3_3=$RTLG3->TLG3; $RTLG3_4=$RTLG3->RTLG3; }
		
		if(empty($RTLG4)) { $RTLG4_1=""; $RTLG4_2="1"; $RTLG4_3=""; $RTLG4_4=""; }
		else { $RTLG4_1=$RTLG4->G4; $RTLG4_2=$RTLG4->TBG4+1; $RTLG4_3=$RTLG4->TLG4; $RTLG4_4=$RTLG4->RTLG4; }
		
		if(empty($RTLG5)) { $RTLG5_1=""; $RTLG5_2="1"; $RTLG5_3=""; $RTLG5_4=""; }
		else { $RTLG5_1=$RTLG5->G5; $RTLG5_2=$RTLG5->TBG5+1; $RTLG5_3=$RTLG5->TLG5; $RTLG5_4=$RTLG5->RTLG5; }
		*/
		?>
		<td><input class="form-control" id="lk1" type="text" name="lk1" maxlength="50" value="<?php echo $RTLG1_1; ?>" /></br>
		<input class="form-control" id="lk2" type="text" name="lk2" maxlength="50" value="<?php echo $RTLG2_1; ?>" /></br>
		<input class="form-control" id="lk3" type="text" name="lk3" maxlength="50" value="<?php echo $RTLG3_1; ?>" /></br>
		<input class="form-control" id="lk4" type="text" name="lk4" maxlength="50" value="<?php echo $RTLG4_1; ?>" /></br>
		<input class="form-control" id="lk5" type="text" name="lk5" maxlength="50" value="<?php echo $RTLG5_1; ?>" /></td>
		<td><input class="form-control" id="rtl11" type="text" name="rt11" maxlength="50" value="<?php echo $RTLG1_2; ?>" readonly /></br>
		<input class="form-control" id="rtl12" type="text" name="rt12" maxlength="50" value="<?php echo $RTLG2_2; ?>" readonly /></br>
		<input class="form-control" id="rtl13" type="text" name="rt13" maxlength="50" value="<?php echo $RTLG3_2; ?>" readonly /></br>
		<input class="form-control" id="rtl14" type="text" name="rt14" maxlength="50" value="<?php echo $RTLG4_2; ?>" readonly /></br>
		<input class="form-control" id="rtl15" type="text" name="rt15" maxlength="50" value="<?php echo $RTLG5_2; ?>" readonly /></td>
		<td><input class="form-control" id="tar11" type="text" name="tar11" maxlength="50" value="<?php echo $RTLG1_3; ?>" /></br>
		<input class="form-control" id="tar12" type="text" name="tar12" maxlength="50" value="<?php echo $RTLG2_3; ?>" /></br>
		<input class="form-control" id="tar13" type="text" name="tar13" maxlength="50" value="<?php echo $RTLG3_3; ?>" /></br>
		<input class="form-control" id="tar14" type="text" name="tar14" maxlength="50" value="<?php echo $RTLG4_3; ?>" /></br>
		<input class="form-control" id="tar15" type="text" name="tar15" maxlength="50" value="<?php echo $RTLG5_3; ?>" /></td>
		<td>
		<select name="l1" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="l2" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="l3" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="l4" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
<select name="l5" class="form-control"> <option value="3">Open</option>
    <option value="1">On Progress</option>
    <option value="2">Selesai</option>
</select></br>
</td>
		</tr></table>
		NIK Anggota     </br>
        <input class="form-control" id="nama1" type="text" name="nama1" maxlength="50" value="" required />
        <input class="form-control" id="nama2" type="hidden" name="nama2" maxlength="50" value="" />
</br></br>
		<?php
		if($this->session->userdata('role')==1)
		{
		?>
		Pengawas Telah Memvalidasi
		<input disabled name="pengawas" type="checkbox" value="<?php echo $this->session->userdata('user_name'); ?>"></br></br>
		Sekretaris Telah Memvalidasi
		<input disabled name="skertaris" type="checkbox" value="1"></br></br>
		<?php
		}
		else
		{
		?>
		Pengawas Telah Memvalidasi
		<input name="pengawas" type="checkbox" value="<?php echo $this->session->userdata('user_name'); ?>"></br></br>
		Sekretaris Telah Memvalidasi
		<input name="skertaris" type="checkbox" value="1"></br></br>
		<?php
		}
		?>
		<input type="submit" class="btn btn-primary" value="Kirim"/>
		</form>
		</div></body></html>